import Page from "$UI/wxsys/comps/reactContainer/page/Page";
import UserFlowBase from '$UI/pcx/userFlowBase';
import "$UI/mobile/processApproval.css";

export default class IndexPage extends Page {
    constructor(...args) {/*{{{*/this.comp = require("_comp").default; this._e = require("_event_").default;/*为代码提示动态插入的辅助代码,不要删除}}}*/
        super(...args);
        this.flowBase = new UserFlowBase(this, false);
    }

    // 页面显示
    onPageReady = (event) => {
        if (!this.params.title) {
            this.params.title = '采购申请单'
        }

        this.flowBase.onPageLoaded(event)
    }
    // 页面加载完成
    onPageShow = (event) => {
        // let a = []
        let selectSupplierList = wx.getStorageSync("selectSupplier");
        console.log(selectSupplierList, "选择下载")
        if (selectSupplierList.list.length) {
            let mainData = this.comp("mainData")
            mainData.setValue("repertoryPurchaseName", selectSupplierList.list[0].name)
            mainData.setValue("repertoryPurchaseId", selectSupplierList.list[0].fid)
        }
    }


    //申请表的刷新后事件
    onMainDataAfterRefresh = (event) => {
        if (!this.params.title) {
            this.params.title = '采购申请单'
        }
        this.flowBase.mainDataAfterRefresh(event)
    }

    // 流转前   
    onWfmuiAdvanceBefore = (event) => {
        wx.showLoading({
            title: this.params.title + '正在流转...'
        })
    }

    // 流转成功
    onWfmuiAdvanceSuccess = (event) => {
        wx.hideLoading()
        this.hint(this.params.title + ' 流转成功', 'success', 1500)
    }

    //采购大类的值改变
    onPurchaseCategorySelectChange = ({ option }) => {
        console.log(option)
        let mainData = this.comp("mainData")
        mainData.setValue("purchaseSubclass", "")
        let filter = []
        let filterobj = {
            name: "purchaseCategory",
            value: option,
            op: "eq"
        }
        filter.push(filterobj)
        this.comp("purchaseSubData").setFilter("_system1_", filter)
        this.comp("purchaseSubData").refreshData()
    }
    //选择组织
    onOrgSelect0Change = ({ option }) => {
        // debugger
        let mainData = this.comp("mainData")
        // console.log(option.rows[0], "后的数据")
        // let curList = option.rows[0]

        // mainData.setValue("purchaseRelevantDep", curList.name)
        // mainData.setValue("purchaseRelevantDepIds", curList.id)
        // mainData.setValue("purchaseRelevantDepFids", curList.fid)

        this.comp("serviceRequestPlatformList").send({
            orgIds: mainData.getValue("purchaseRelevantDepFids")
        })

    }
    //选择平台
    onSelectPlatformChange = (res) => {
        console.log(res)
    }


    //删除
    onIcon1Click = (event/*{{{*/ = this._e.Icon_onClick/*}}}*/) => {

    }
}

jsonStringToOrgUnits(getValueByUrl(concat('/ent/main/orgmanage/gethandlerbyroles?orgRole=tech_center&otherRoles=tech_approval&userFID=', '/94E65562360C4D83BA9EE064A3109082.ogn/1BC5EDD6500A4BDCBE97FAFDCE12CA0D.dpt'), ''))

jsonStringToOrgUnits(getValueByUrl(concat('/ent/main/orgmanage/gethandlerbyroles?orgRole=tech_center&otherRoles=tech_approval&userFID=', findActivityFirstCreatorFID('START')), ''))